import request from '@/utils/request'

enum Api {
  getSkuListApi = '/admin/product/findBySpuId',
  // 添加SkuInfo
  saveSkuInfoApi = '/admin/product/saveSkuInfo',
  //根据spuid 查找下面的sku列表
  findBySpuIdApi = '/admin/product/findBySpuId',

  //获取所有的sku列表
  getAllSkuList = '/admin/product/list',

  // sku商品上架
  skuInfoOnSaleApi = '/admin/product/onSale',
  // sku商品下架
  skuInfoCancelSaleApi = '/admin/product/cancelSale',

  //删除sku

  deleteSkuInfoApi = '/admin/product/deleteSku',

  // 根据skuid查询一个skuInfo对象数据
  getSkuInfoApi = '/admin/product/getSkuById'

}

//添加SkuInfo数据
export const reqSaveSkuInfo = (skuInfo: any) => {
  return request.post<any, any>(Api.saveSkuInfoApi, skuInfo)
}

// 根据spuId获取sku列表

export const reqFindBySpuId = (spuId: number) => {
  return request.get(Api.findBySpuIdApi + `/${spuId}`)
}
export const reqGetSkuListData = (spuId: any) => {
  return request.get<any, any>(Api.getSkuListApi, spuId)
}

// 查找所有的SKU列表
export function reqGetAllSkuList(page: number, limit: number) {
  return request.get<any, any>(Api.getAllSkuList + `/${page}/${limit}`)
}

//sku商品上架
export const reqSkuInfoOnSale = (skuId: number) => {
  return request.get(Api.skuInfoOnSaleApi + `/${skuId}`)
}

// sku商品下架
export const reqSkuInfoCancelSale = (skuId: number) => {
  return request.get(Api.skuInfoCancelSaleApi + `/${skuId}`)
}

// 删除skuInfo商品
export const reqDeleteSkuInfo = (skuId: number) => {
  return request.delete(Api.deleteSkuInfoApi + `/${skuId}`)
}

//根据skuId查询一个skuInfo对象数据
export const reqGetOneSkuInfo = (skuId: number) => {
  return request.get(Api.getSkuInfoApi + `/${skuId}`)
}
